package com.wn.video.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.blankj.utilcode.util.ToastUtils
import com.wn.common.db.entity.VideoInfo
import com.wn.common.model.VideoAction
import com.wn.framework.adapter.BaseBindViewHolder
import com.wn.framework.adapter.BaseRecyclerViewAdapter
import com.wn.video.databinding.LayoutVideoItemBinding
import dagger.hilt.android.scopes.ActivityScoped
import javax.inject.Inject

/**
 * @Author: wn
 * @Date: 2024/11/11 15:59
 * @Description: 视频Adapter
 */
@ActivityScoped
class VideoAdapter @Inject constructor() :
  BaseRecyclerViewAdapter<VideoInfo, LayoutVideoItemBinding>() {
  /**
   * 子类通过 xml实现 ViewBinding，父类提供了 LayoutInflater ，viewType
   * 可以根据不同的 viewType传递不同的 viewBinding -- when
   */
  override fun getViewBinding(
    layoutInflater: LayoutInflater,
    parent: ViewGroup,
    viewType: Int,
  ): LayoutVideoItemBinding = LayoutVideoItemBinding.inflate(layoutInflater, parent, false)

  /**
   * 子类重写该方法绑定数据
   * 重写 [getViewBinding] 即可实现不同ViewHolder传递
   */
  override fun setViewBinding(
    holder: BaseBindViewHolder<LayoutVideoItemBinding>,
    item: VideoInfo?,
    position: Int,
  ) {
    item?.apply {
      holder.binding.videoInfo = this
      holder.binding.videoAction = VideoAction("11", "22", "33")
      holder.binding.includeVideoAction.tvLike.setOnClickListener {
        ToastUtils.showShort("新功能敬请期待")
      }
    }

  }
}